/*******************************************************************************
 * Copyright (c) 2012 Clever Devices.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Public License v3.0
 * which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/gpl.html
 * 
 * Contributors:
 * 	Clever Devices Interns - 
 * 	Alex Frankel, Andria Young, Kevin Thomas, Nicholas Culpepper, Taner Oztimurlenk, Thomas Volberg
 ******************************************************************************/
package com.framework.rewards;

import java.util.ArrayList;
import java.util.Arrays;

import android.content.Intent;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.TextView;

import com.framework.cleverstop_tentative.R;
import com.framework.rewards.Achievements;
import com.framework.menu.MenuAdapter;
import com.framework.menu.MenuItem;
import com.slidingmenu.lib.SlidingMenu;
import com.slidingmenu.lib.app.SlidingActivity;

public class Achievements extends SlidingActivity implements OnItemClickListener{
	
	public final int REWARDS = 0;
	public final int BOARDS = 1;
	public final int FARES = 2;
	public final int BUSTIME = 3;
	public final int SETTINGS = 4;
	
	public final int RIDERSHIP = 0;
	public final int GAMESACHIEVE = 1;
	
	ListView mainList;
	MenuAdapter listData;
	ListAdapter realListData;
	Button test;
	
	@Override
	public void onCreate(Bundle savedInstanceState){
		super.onCreate(savedInstanceState);

	    setContentView(R.layout.customer_customer);
	    setSlidingMenu();
	    ListView mainList = (ListView) findViewById(R.id.customerList);
	    
	    String [] list = { "Ridership Points", "Game Achievements" };

	    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,R.layout.slider_pullout_row,list);
	    mainList.setAdapter(adapter);
	    
	    mainList.setOnItemClickListener(this);  
	    
		Drawable d = this.getResources().getDrawable(R.drawable.layout_background);
		getActionBar().setBackgroundDrawable(d);
		getActionBar().setHomeButtonEnabled(true);
	}

	/**
	 * Sets up properties for the sliding menu this will keep properties
	 * consistent across all activities
	 */
	public void setSlidingMenu() {
		// sets view that slides out from left, this will be standard across all
		// menus
		// allowing for quick and intuitive navigation
		setBehindContentView(R.layout.persistent_menu_list);
		
		
		MenuItem[] menuItems = {
			new MenuItem("Rewards",R.drawable.rewaredsicon, "1"),
			new MenuItem("Boards",R.drawable.boardsicon, ""),
			new MenuItem("Fares", R.drawable.faresicon, ""),
			new MenuItem("BusTime", R.drawable.bustimeicon, ""),
			new MenuItem("Settings", R.drawable.settinsicon, "")
		};
				
		ArrayList<MenuItem> items = new ArrayList<MenuItem>();
		for(int i = 0; i<menuItems.length;i++)
			items.add(menuItems[i]);

		listData = new MenuAdapter(this,R.layout.listview_item_row,items);
		mainList = (ListView) findViewById(R.id.menuList);

		// dynamically add items to listView
		// did below as a test, but can easily add items based on the section of
		// app you are in
		// listData.insert("BusTime", list.size());

		mainList.setAdapter(listData);
		mainList.setOnItemClickListener(this);

		getSlidingMenu().setBehindOffsetRes(R.dimen.DistanceFromSide);
		getSlidingMenu().setBehindScrollScale(0.5f);
		getSlidingMenu().setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
		//getSlidingMenu().setBehindTouchMode(SlidingMenu.TOUCHMODE_FULLSCREEN);
		getSlidingMenu().setActivated(true);

	}
	
	//@Override
	public void onItemClick(AdapterView<?> parent, View view, int index, long id) {
		//super.onItemClick(parent, view, index, id);
		
		if(parent.getId()==R.id.customerList){
			switch(index){
			case RIDERSHIP:
				Intent Ridership = new Intent("com.framework.rewards.RIDERSHIP");
				startActivity(Ridership);
				break;
			case GAMESACHIEVE:
				Intent GamesAchieve = new Intent("com.framework.rewards.GAMESACHIEVE");
				startActivity(GamesAchieve);
				break;
			}
		}
		if(parent.getId()==R.id.menuList)
		{
			switch (index) {
			
			// this is where each intent will be started for all of your
			// respective sections. Look to the "BUSTIME" case as a model
			case REWARDS:
				Intent Rewards = new Intent("com.framework.rewards.REWARDS");
				startActivity(Rewards);
				break;
			case BOARDS:
				Intent Customer = new Intent("com.framework.customerservice.CUSTOMER");
				startActivity(Customer);
				break;
			case FARES:
				Intent Fares = new Intent("com.framework.cleverstop_tentative.FARESMAINACTIVITY");
				startActivity(Fares);
				break;
			case BUSTIME:
				Intent BusTime = new Intent(
						"com.framework.cleverstop_tentative.BUSTIMEMAINACTIVITY");
				startActivity(BusTime);
				break;
			case SETTINGS:
				break;
				
			}
		}
		
	}
	
}
